package com.example.user.app;

import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Created by hzn on 14-6-26.
 */
public class ContactsAdapter extends CursorAdapter {
    private final LayoutInflater mFactory;

    public ContactsAdapter(Context context, Cursor c) {
        super(context, c, false);

        mFactory = LayoutInflater.from(context);
    }

    @Override
    public View newView(Context context, Cursor cursor, ViewGroup parent) {


        return mFactory.inflate(android.R.layout.simple_list_item_1, parent, false);
    }

    @Override
    public void bindView(View view, Context context, Cursor cursor) {
        Contact contact = Contact.createFromCursor(cursor);

        TextView sub = (TextView)view.findViewById(android.R.id.text1);
        sub.setText(contact.getName());
    }
}
